/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deti.es.ukni.persistence.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author eurico
 */
@Entity
@Table(name = "COMMENT_AUDIO")
@NamedQueries({@NamedQuery(name = "CommentAudio.findAll", query = "SELECT c FROM CommentAudio c"), @NamedQuery(name = "CommentAudio.findByRefidcomment", query = "SELECT c FROM CommentAudio c WHERE c.commentAudioPK.refidcomment = :refidcomment"), @NamedQuery(name = "CommentAudio.findByRefidaccount", query = "SELECT c FROM CommentAudio c WHERE c.commentAudioPK.refidaccount = :refidaccount"), @NamedQuery(name = "CommentAudio.findByRefidaudio", query = "SELECT c FROM CommentAudio c WHERE c.commentAudioPK.refidaudio = :refidaudio")})
public class CommentAudio implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CommentAudioPK commentAudioPK;
    @JoinColumn(name = "REFIDACCOUNT", referencedColumnName = "IDACCOUNT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Account account;
    @JoinColumn(name = "REFIDAUDIO", referencedColumnName = "IDAUDIO", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Audio audio;
    @JoinColumn(name = "REFIDCOMMENT", referencedColumnName = "IDCOMMENT", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Comment comment;

    public CommentAudio() {
    }

    public CommentAudio(CommentAudioPK commentAudioPK) {
        this.commentAudioPK = commentAudioPK;
    }

    public CommentAudio(int refidcomment, int refidaccount, int refidaudio) {
        this.commentAudioPK = new CommentAudioPK(refidcomment, refidaccount, refidaudio);
    }

    public CommentAudioPK getCommentAudioPK() {
        return commentAudioPK;
    }

    public void setCommentAudioPK(CommentAudioPK commentAudioPK) {
        this.commentAudioPK = commentAudioPK;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public Audio getAudio() {
        return audio;
    }

    public void setAudio(Audio audio) {
        this.audio = audio;
    }

    public Comment getComment() {
        return comment;
    }

    public void setComment(Comment comment) {
        this.comment = comment;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (commentAudioPK != null ? commentAudioPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CommentAudio)) {
            return false;
        }
        CommentAudio other = (CommentAudio) object;
        if ((this.commentAudioPK == null && other.commentAudioPK != null) || (this.commentAudioPK != null && !this.commentAudioPK.equals(other.commentAudioPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "deti.es.ukni.persistence.entity.CommentAudio[commentAudioPK=" + commentAudioPK + "]";
    }

}
